package org.crazyit.activiti_d2._4_Destory;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;

import java.net.URL;

public class Destroy {

    public static void main(String[] args) {

        //1. 进行初始化并且返回默认的ProcessEngine 实例
        ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
        System.out.println("调用getDefaultProcessEngine 方法后引擎数量: " + ProcessEngines.getProcessEngines().size());

        //2. 调用销毁方法
        ProcessEngines.destroy();
        //最终结果为0
        System.out.println("调用destory 方法后引擎数量: " + ProcessEngines.getProcessEngines().size());

        //3. 得到资源文件的URL 实例
        ClassLoader classLoader = Destroy.class.getClassLoader();
        URL url = classLoader.getResource("activiti-context_1.xml");

        //4. 调用retry 方法创建ProcessEngine 实例
        ProcessEngines.retry(url.toString());
        System.out.println("只调用retry 方法后引擎数量: " + ProcessEngines.getProcessEngines().size());

        //5. 调用销毁方法, 没有效果
        ProcessEngines.destroy();
        System.out.println("调用destroy 无效果, 引擎数量: " + ProcessEngines.getProcessEngines().size());

    }

}
